<?PHP
/**
 * @version		$Id: mypostgresql.php 2011.08.11 thierry $
 * @package		site.model
 * @subpackage	com_projid
 * @copyright	Copyright (C) 2011 Projid All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die('Restricted access');
 class MyPostgreSQL{

	private $_item;
	private $_requete;
	public $_error;
	private $_resource;
	public $_result;
	

public function __construct($item){
	$this->_item = $item;
	$this->_requete = $item->requete;
	$this->_error = false;
	$this->_result = "";
	}

function Connection(){
	$item=$this->_item;
	$this->_resource = pg_connect("host={$item->host} dbname={$item->base} user={$item->user} password={$item->password}");
	return $this->_resource;
	}
function DoRequete(){
	$this->_error=false;
		if (!$result = pg_query($this->_resource, $this->_requete)) {
		  $this->_error="La requête PostgreSQL n'a pas fonctionnée : \n\r".$this->_requete;
		  return false;
		}

		while ($row = pg_fetch_row($result)) {
			$resultat[] = $row;
		}
		$this->_result=$resultat;
		return true;
	}
}